<template>
  <!--我的礼品卡-->
  <div>
    <div v-if="goodsList.length<=0" class="null_content">
      <ul>
        <li><img src="../../../assets/null.png" alt="" width="155"></li>
        <li>这里空空如也</li>
      </ul>
    </div>
    <div class="msg" v-for="item in goodsList">
      <div class="weui-media-box weui-media-box_appmsg">
        <div class="weui-media-box__hd">
          <img :src="item.coverImg | imgPathFilter" alt="" class="weui-media-box__thumb">
        </div>
        <div class="weui-media-box__bd">
          <h4 class="weui-media-box__title">{{item.goodsName}}</h4>
          <p class="weui-media-box__desc">{{item.vipCardNo}}</p>
        </div>
      </div>
      <p class="status" v-if="item.vipCardState==0">
        <wv-button type="default" :plain="true" @click="goActivateGiftCard(item.accountGoodsId)">激活</wv-button>
        <wv-button type="default" :plain="true" @click="goZhuanZeng(item.accountGoodsId)">转赠</wv-button>
      </p>
      <p class="status" v-if="item.vipCardState==1">
        <span class="date">激活时间：{{item.activateDate}}</span>
        <span class="success">已激活</span>
      </p>
      <p class="status" v-if="item.vipCardState==9">
        <span class="date">转增时间：{{item.transferDate}}</span>
        <span class="success">已转增</span>
      </p>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {getUserGiftcard} from '../../../../test/unit/http'
  import {Toast} from 'we-vue'
  export default {
    name: '',
    props: {},
    data() {
      return {
        goodsList: []
      };
    },
    methods: {
      goActivateGiftCard(accountGoodsId){
        this.$router.push({path: 'wanshanziliao', query: {accountGoodsId: accountGoodsId}})
      },
      goZhuanZeng(accountGoodsId){
        this.$router.push({path: 'zhuanzeng', query: {accountGoodsId: accountGoodsId}})
      },
      getUserGiftcardData(){
        getUserGiftcard({}).then(res => {
          console.log(res);
          if (res.code == 100) {
            this.goodsList = res.object.rows;
          }
        })
      }
    },
    created() {
      this.getUserGiftcardData();
    },
    components: {}
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .null_content{
    padding-top:50%;
    li:nth-child(2){
      margin: 10px 0 20px;
      color: #bababa;
      font-size: 14px;
    }
  }
  .weui-btn + .weui-btn {
    margin-top: 0;
  }

  .msg {
    position: relative;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    .weui-media-box__desc {
      font-size: 14px;
      color: #999;
    }
    .status {
      padding-right: 15px;
      text-align: right;
      padding-left: 15px;
      .date {
        font-size: 12px;
        color: #999;
        float: left;
      }
      .success {
        color: #666;
        font-size: 15px;
      }
      button {
        border-radius: 25px;
        display: inline-block;
        width: 72px;
        font-size: 15px;
        color: #111;
        margin-left: 10px;
        line-height: 1.6
      }
    }
    &:last-child {
      border-bottom: none;
    }
  }

</style>
